import pymysql


def main():
    conn = pymysql.connect(host='182.247.245.27',port=10190,user='root',password='dyk19891019',db='school',charset='utf8')
    try:
        with conn.cursor() as cursor:
            rel = cursor.execute('insert into tb_student values(9,"李四",1,"1989-10-19",1002,"云南昆明")')
            if rel == 1:
                print('添加成功')


            conn.commit()
    except pymysql.MySQLError as error:
        print(error)
        conn.rollback()
    finally:
        conn.close()



if __name__ == '__main__':
    main()


